1804C - Pull Your Luck - CodeForces Solution


brute force math number theory

Please click on ads to support us..

C++ Code:

#include <bits/stdc++.h>
using namespace std;

//-------TEMPLATES-------
template<typename... T>
void see(T&... args) { ((cin >> args), ...);}
template<typename... T>
void put(T&&... args) { ((cout << args << " "), ...);}

//--------MACROS---------
#define cpu() ios::sync_with_stdio(false); cin.tie(nullptr)
#define ll long long
#define vi vector<int>
#define pb push_back
#define rep(i,a,b) for (int i=a; i<b; ++i)
#define rev(i,a,b) for (int i=a; i>b; --i)
#define pii pair<int,int>
#define F first
#define S second
#define seea(a,x,y) for(int i=x;i<y;i++){cin>>a[i];}

//-----CONSTANTS------
const ll inf = INT64_MAX;
const ll minf = INT64_MIN;
const ll mod = 1e9+7;
const ll N = 1e5+5;

ll moved(ll f, int x, int n){
  ll temp = (f*(f+1))/2;
  return (temp + x)%n;
}

void solve(){
  int n,x,p;
  cin>>n>>x>>p;
  for(ll i=1;i<=min(2*n,p);i++){
    if (moved(i,x,n)== 0){
      cout<<"Yes\n";
      return;
    }
  }
  cout<<"No\n";
}
    
signed main(){
  cpu();
  int t;
  cin>>t;
  while(t--) solve();
}


Comments

Submit
0 Comments
More Questions

Partitioning binary strings
Special sets
Smallest chosen word
Going to office
Color the boxes
Missing numbers
Maximum sum
13 Reasons Why
Friend's Relationship
Health of a person
Divisibility
A. Movement
Numbers in a matrix
Sequences
Split houses
Divisible
Three primes
Coprimes
Cost of balloons
One String No Trouble
Help Jarvis!
Lift queries
Goki and his breakup
Ali and Helping innocent people
Book of Potion making
Duration
Birthday Party
e-maze-in
Bricks Game
Char Sum